package caiwei.android_study_sample.activity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import caiwei.android_study_sample.R;

public class Android07UIBaseSampleGridView extends Activity
{
	private int[] mImages=new int[]{
			R.drawable.sample_0,
			R.drawable.sample_1,
			R.drawable.sample_2,
			R.drawable.sample_3,
			R.drawable.sample_4,
			R.drawable.sample_5,
			R.drawable.sample_6,
			R.drawable.sample_7
	};
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.layout_gridview);
		GridView _GridView=(GridView)findViewById(R.id.gridView1);
		_GridView.setAdapter(new ImageAdapter());
		
	}
	
	class ImageAdapter extends BaseAdapter
	{

		@Override
		public int getCount()
		{
			// TODO Auto-generated method stub
			return mImages.length;
		}

		@Override
		public Object getItem(int position)
		{
			// TODO Auto-generated method stub
			return mImages[position];
		}

		@Override
		public long getItemId(int position)
		{
			// TODO Auto-generated method stub
			return position;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent)
		{
			ImageView _ImageView=new ImageView(Android07UIBaseSampleGridView.this);
			_ImageView.setImageResource(mImages[position]);
			return _ImageView;
		}
		
	}
}
